<template>
	<view class="container">
		<view class="mainTitle">
			可选方案
		</view>
		<scroll-view class="list" scroll-y="true"  v-if='list.length>0'>
			<view class="box" v-for="(item,i) in list" :key='i' @click="selectPlan(i)">
				<plan-item :select='true' :isActive='i===active?true:false' :planInfo="item"></plan-item>
			</view>
		</scroll-view>
		<no-list tipInfo='暂无可选的洗车方案' v-else></no-list>
	</view>
</template>
<script>
	import {washMenu} from "@/untils/api"
	export default {
		data() {
			return {
				list:[],
				active:-1,
				cartId:''
			};
		},
		mounted(){
			this.cartId = this.$mp.query.cartId
			this.getWashMenu()
		},
		methods:{
			getWashMenu(){
			  washMenu({cartId: this.cartId}).then((res) => {
				if(res.code - 200 === 0){
					this.list = res.data
				}
			  })
			},
			selectPlan(i){
				this.active = i
				setTimeout(() => {
					this.$setStorageSync('selectPlanInfo', this.list[i])
					const seriveParams = this.$getStorageSync('seriveParams')
					seriveParams.menuId = this.list[i].id
					this.$setStorageSync('seriveParams', seriveParams)
					uni.navigateBack({
						delta:1,
					})
					// uni.redirectTo({
					// 	url:`/subpackage/orderWashCar/index?cartId=${this.cartId}&menuId=${this.list[i].id}`
					// })
				}, 500)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		height: 100%;
		background: #eee;
		overflow: hidden;
		.list{
			height: calc(100% - 160rpx);
		}
		.box{
			margin-bottom: 30rpx;
		}
	}

</style>
